<!--包含头部文件-->
{include file="public/header" /}
<script type="text/javascript" src="__STATIC__/js/city.js"></script>
<body>
<article class="page-container">
    <form class="form form-horizontal" action="" method="post" id="form-shop-add">
        <input type="hidden" name="id" value="{$shop_info.id}">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>店铺名称：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <input type="text" class="input-text" value="{$shop_info.shop_name}" placeholder="" id="shop_name" name="shop_name"/>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>主营类目：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <select name="category" class="select" style="width: auto">
                    {volist name="cate" id="vo"}
                    <option value="{$vo.id}" {if condition="$shop_info['category'] eq $vo['id']"}selected{/if}>{$vo.name}</option>
                    {/volist}
                </select>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>是否自营：</label>
            <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                <div class="radio-box">
                    <input name="is_self" value="1" type="radio" id="is_self-1" {if condition="$shop_info['is_self'] eq 1"}checked{/if}>
                    <label for="is_self-1">是</label>
                </div>
                <div class="radio-box">
                    <input type="radio" value="0" id="is_self-2" name="is_self" {if condition="$shop_info['is_self'] eq 0"}checked{/if}>
                    <label for="is_self-2">否</label>
                </div>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>店铺联系人：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <input type="text" class="input-text" value="{$shop_info.shop_keeper}" placeholder="" id="shop_keeper" name="shop_keeper"/>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>店铺联系人电话：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <input type="tel" class="input-text" placeholder="" value="{$shop_info.phone}" name="phone" id="phone">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>座机：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <input type="text" class="input-text" placeholder=""value="{$shop_info.shop_phone}" name="shop_phone" id="shop_phone">
            </div>
        </div>

        <!--<div class="row cl">-->
            <!--<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>店铺地址：</label>-->
            <!--<div class="formControls col-xs-5 col-sm-5">-->
                <!--<input type="text" class="input-text" placeholder="选择位置" value="{$shop_info.address}" onclick="map('查看位置','{:url('shop/map')}','1200','500')" readonly name="address" id="address">-->
                <!--<input type="hidden" class="input-text" name="lng" id="lng" value="{$shop_info.lng}">-->
                <!--<input type="hidden" class="input-text" name="lat" id="lat" value="{$shop_info.lat}">-->
                <!--<input type="hidden" class="input-text" placeholder="" value="{$shop_info.province}" name="province" id="province">-->
                <!--<input type="hidden" class="input-text" placeholder="" value="{$shop_info.city}" name="city" id="city">-->
                <!--<input type="hidden" class="input-text" placeholder="" value="{$shop_info.citycode}" name="citycode" id="citycode">-->
            <!--</div>-->
        <!--</div>-->

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>店铺地址：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <script>
                    selcity('pro','city','county','{$shop_info.province}','{$shop_info.city}','{$shop_info.county}')
                </script>
                <input type="text" value="{$shop_info.address}" class="input-text" style="margin-top: 10px;line-height: 20;font-size: 20px" placeholder="请填写详细地址" name="address" id="address">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>状态：</label>
            <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                <div class="radio-box">
                    <input name="status" value="1" type="radio" id="status-1" {if condition="$shop_info['status'] eq 1"}checked{/if}>
                    <label for="status-1">启用</label>
                </div>
                <div class="radio-box">
                    <input type="radio" value="0" id="status-2" name="status" {if condition="$shop_info['status'] eq 0"}checked{/if}>
                    <label for="status-2">关闭</label>
                </div>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>店铺等级：</label>
            <div class="formControls col-xs-8 col-sm-8">
                <select name="grade">
                    <option value="1" {if condition="$shop_info['grade'] eq 1"}selected{/if}>天猫商家</option>
                    <option value="2" {if condition="$shop_info['grade'] eq 2"}selected{/if}>大型卖场</option>
                    <option value="3" {if condition="$shop_info['grade'] eq 3"}selected{/if}>商超</option>
                    <option value="4" {if condition="$shop_info['grade'] eq 4"}selected{/if}>个人实体店</option>
                </select>
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>商品图片：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <div class="lubo_pic" onclick="img_div(this)">
                    <img src="{$shop_info['logo']}" width="240px" height="90px" id="img_show">
                </div>
                <input id="upload_img" name="activity_img" accept="image/*" onchange="uploadImgFile(this)" type="file" style="display: none"/>
                <input name="logo" value="{$shop_info['logo']}" type="hidden" />
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">备注：</label>
            <div class="formControls col-xs-5 col-sm-5">
                <textarea name="" cols="" rows="" class="textarea" placeholder="说点什么...100个字符以内" dragonfly="true"
                          onKeyUp="$.Huitextarealength(this,100)"></textarea>
                <p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
            </div>
        </div>

        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

<!--包含footer文件-->
{include file="public/footer" /}

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__STATIC__/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="__STATIC__/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="__STATIC__/js/ajaxfileupload.js"></script>

<script type="text/javascript">


    //点击图片上传
    function img_div(e) {
        $("#upload_img").click()
    }
    //    上传图片
    function uploadImgFile(even) {
        var id = even.id;
        $.ajaxFileUpload
        (
            {
                url: '{:url("Upload/img_upload")}',//需要链接到服务器地址
                secureuri: false,
                fileElementId: id,
                dataType: 'json',
                success: function (data)  //服务器成功响应处理函数
                {
                    var path = data.data.path;
                    var host_path = data.data.host_path;
                    $("#"+id).next().val(path);
                    $("#"+id).prev().children(':first').attr('src',host_path);
                },
                error: function (data, status, e)//服务器响应失败处理函数
                {
                    alert(e);
                }
            }
        )
        return false;

    }

    $(function () {
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form-shop-add").validate({
            rules:{
                shop_name:{
                    required:true,
                },
                shop_keeper:{
                    required:true,
                },
                phone:{
                    required:true,
                    isMobile:true,
                },
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                var arr = $('#form-shop-add').serialize();
                $.ajax({
                    url:"{:url('shop/shop_edit')}",
                    type:"post",
                    data:arr,
                    dataType:"json",
                    success:function (data) {
                        if (data.code == 200){
                            layer.alert('修改成功',{
                                skin: 'layui-layer-molv' //样式类名 自定义样式
                                ,closeBtn: 0  // 是否显示关闭按钮
                                ,anim: 1 //动画类型
                                ,btn: '确认'//按钮
                                ,icon: 6  // icon
                                ,yes:function(){
                                    layer.closeAll();
                                    parent.location.reload();
                                }
                            })
                        }else {
                            layer.alert('修改失败'+data.msg+'',{
                                skin: 'layui-layer-molv' //样式类名 自定义样式
                                ,closeBtn: 0  // 是否显示关闭按钮
                                ,anim: 1 //动画类型
                                ,btn: '确认'//按钮
                                ,icon: 6  // icon
                            })
                        }

                    },
                    error:function () {
                        alert("修改失败")
                        return false;
                    }
                })

            }
        });

    });
</script>

<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>